﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
   public class SanBayDAO
    {
       public List<SanBayDTO> GetAll()
       {
           String sql = "SELECT * ";
           sql += "from SanBay";
           SqlConnection conn = DataProvider.ConnectDB("QLVCB.mdf");
           SqlCommand cmd = new SqlCommand(sql, conn);
           SqlDataReader reader = cmd.ExecuteReader();
           List<SanBayDTO> ds = new List<SanBayDTO>();
           while (reader.Read())
           {
               SanBayDTO sb = new SanBayDTO();
               sb.MaSanBay= reader.GetString(0);
               sb.TenSanBay = reader.GetString(1);
              
               ds.Add(sb);

           }
           conn.Close();
           return ds;
       }
    }
}
